function printListFromTailToHead(head) {
  // write code here
  /*function ListNode(x){
    this.val = x;
    this.next = null;
}*/
//   var arr = [];
//   var phead = head;
//   while (phead.next !== null) {
//     arr.unshift(phead.val);
//     phead = phead.next;
//   }
//   return arr;
    var arr = []
    var currentnode = head
    while(currentnode.val!==null)
    {
        arr.unshift(currentnode.val)
        currentnode = currentnode.next

    }
    return arr
}






